package top.go2do.deviceSync.business.device.module;

import jakarta.persistence.*;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * @Description 设备主表
 * @Author xingyuji
 * @CreateTime 2025/4/17 9:20
 */
@Entity
@Table(name = "device", uniqueConstraints = {
        @UniqueConstraint(name = "idx_unique_app_device", columnNames ={"app_id", "device_id"})
})
@Data
public class DevicePO {
    @Id
    @Column(name = "device_id", columnDefinition = "VARCHAR(32) COMMENT '设备唯一标识（如UUID或设备可获取的标识）'")
    private String deviceId;

    @Column(name = "app_id", nullable = false, columnDefinition = "VARCHAR(32) COMMENT '所属应用ID'")
    private String appId;

    @Column(name = "device_type", nullable = false, columnDefinition = "VARCHAR(32) COMMENT '设备类型（IOS/Android）'")
    private String deviceType;

    @Column(name = "device_model", nullable = false, columnDefinition = "VARCHAR(32) COMMENT '设备型号（Huawei）'")
    private String deviceModel;

    @Column(name = "status", nullable = false, columnDefinition = "TINYINT UNSIGNED DEFAULT 1 COMMENT '1正常,2冻结'")
    private Integer status;

    @Column(name = "heartbeat_interval", nullable = false, columnDefinition = "INT UNSIGNED DEFAULT 60 COMMENT '心跳间隔（秒，如设备每60秒上报一次状态）'")
    private Integer heartbeatInterval;

    @Column(name = "last_online_time", nullable = false, insertable = false, columnDefinition = "DATETIME(6) DEFAULT CURRENT_TIMESTAMP(6) COMMENT '最后在线时间'")
    private LocalDateTime lastOnlineTime;

    @Column(name = "created_at", nullable = false, insertable = false, updatable = false, columnDefinition = "DATETIME(6) DEFAULT CURRENT_TIMESTAMP(6) COMMENT '注册时间'")
    private LocalDateTime createdAt;

}
